package com.ruoyi.project.ins.domain;

import com.ruoyi.framework.aspectj.lang.annotation.Excel;
import com.ruoyi.framework.web.domain.BaseEntity;
import com.ruoyi.project.ins.utils.SmsUtils;
import com.ruoyi.project.ins.utils.UserAccountUtils;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.Email;

@EqualsAndHashCode(callSuper = true)
@Data
public class InsRegister extends BaseEntity {
    private static final long serialVersionUID = 1L;

    private Long id;

    @Email(message = "邮箱格式不正确")
    @Excel(name = "邮箱账户", type = Excel.Type.ALL)
    private String emailAccount;

    @Excel(name = "取码地址", type = Excel.Type.EXPORT)
    private String codeAddress;

    @Excel(name = "ins账号", type = Excel.Type.EXPORT)
    private String userAccount;

    @Excel(name = "注册状态", type = Excel.Type.EXPORT, readConverterExp = "0=未注册,1=注册中,2=注册成功,3=注册失败")
    private String status;

    public void setDefaultStatus() {
        this.status = "0";
    }

    public void setRandomUserAccount() {
        this.userAccount = UserAccountUtils.generateUsername();
    }

    public void generateCodeAddress() {
        this.codeAddress = SmsUtils.generateSmsUrl(this.emailAccount);
    }
}
